<?php
$g4_path = "../"; 
require_once ($g4_path.'common.php');

$title = "Super admin";
$menu = 5;
require_once ('./admin.head.php');
require_once ('./admin.lib.php');

$tpl = new Template_;
$tpl->template_dir = './tpl';
$tpl->compile_dir = './tpl/compile';

$_sqlWhere = $_makeLink = $keyword = NULL; 
$data = $_tplSetting = array();

if(isset($_GET['cate1']) || isset($_GET['cate2'])) {
    $cate1 = $_GET['cate1'];
    $cate2 = isset($_GET['cate2']) ? $_GET['cate2'] : NULL;
    $_sqlWhere = _makeSqlWhere($_sqlWhere, 'course', $cate1);
    $_sqlWhere = _makeSqlWhere($_sqlWhere, 'student', $cate2);
}

$nowPage = isset($_GET['page']) ? $_GET['page'] : 1; 
$perPage = 10;

$_res = sql_fetch("SELECT count(no) as cnt FROM coursevaluation ".$_sqlWhere);
$totalPage = ceil($_res['cnt']/$perPage);

if(( ($nowPage > $totalPage) && $nowPage > 1) || ($nowPage < 1)) {
    alert("페이지 번호가 잘못되었습니다.");
}
$_sqlLimitPage = ($nowPage-1)*$perPage; 
$_sqlOrder = " ORDER BY no DESC"; 
$_sqlLimit = " LIMIT $_sqlLimitPage, $perPage"; 
$sql = 'SELECT * FROM coursevaluation '.$_sqlWhere.$_sqlOrder.$_sqlLimit;


$scoreArray = array('0'=>'', '1'=>'하','5'=>'중','10'=>'상');
$_res = sql_query($sql);
while($_ret = sql_fetch_array($_res)) {
    $_ret['memo'] = htmlspecialchars(stripslashes($_ret['memo'])); 
    $_temp = sql_fetch_array(sql_query("SELECT mb_name FROM g4_member WHERE `mb_no`='".$_ret['student']."'")); 
    $_ret['studentname'] = $_temp['mb_name']; 
    $_ret['date'] = print00($_ret['date']); 
    $_ret['month'] = print00($_ret['month']); 
    $_ret['pron'] = $scoreArray[$_ret['pron']]; 
    $_ret['voca'] = $scoreArray[$_ret['voca']]; 
    $_ret['conv'] = $scoreArray[$_ret['conv']]; 
    $_ret['gram'] = $scoreArray[$_ret['gram']]; 
    $data[] = $_ret; 
}

if(!$totalPage) {
    $_tplSetting['nodata'] = TRUE; 
}
$_tplSetting['paging'] = get_paging($perPage,$nowPage,$totalPage,"./superCourseEval.php?page=",makelink(array('page')));
$tpl->assign('data', $data);
$tpl->assign('set', $_tplSetting);

$tpl->define('basic',"superCourseEval.html");
$tpl->print_('basic');

require_once('teacherinc/teacher_category.php');
require_once('admin.foot.php');
